package cnsukidayo.com.gitee.controller.content;

import cnsukidayo.com.gitee.model.params.CreateUserParam;
import cnsukidayo.com.gitee.model.params.DonatePetParam;
import cnsukidayo.com.gitee.model.support.BaseResponse;
import cnsukidayo.com.gitee.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author sukidayo
 * @date: 2023/3/13 14:23
 */
@RestController("ContentUserController")
@RequestMapping("/content/user")
public class UserController {

    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @ApiOperation("创建用户")
    @PostMapping(value = "createUser")
    public BaseResponse<String> createUser(@RequestBody @Validated CreateUserParam createUserParam) {
        userService.createUser(createUserParam);
        return BaseResponse.ok("用户创建成功!");
    }

    @GetMapping(value = "ping")
    public BaseResponse<String> ping() {
        return BaseResponse.ok("pong!");
    }

    @ApiOperation("用户捐款给收留所")
    @PostMapping("donatePetShelter")
    public void donatePetShelter(@RequestBody @Validated DonatePetParam donatePetParam) {
        userService.donatePetShelter(donatePetParam);
    }

    @ApiOperation("平台总交易数量")
    @GetMapping("count")
    public BaseResponse<Integer> count() {
        return BaseResponse.ok(userService.count());
    }


}
